/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * getFeeList.java
 *
 * Created on 2011-5-26, 11:30:42
 */
package junchangmis.student;

import junchangmis.*;
import java.util.Vector;
import javax.swing.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.StringTokenizer;
import junchangmis.codecSetting.*;
import publicmethod.*;

/**
 *
 * @author developers
 */
public class getFeeList extends javax.swing.JDialog {

    MainFrame parent;
    Vector<String> names = new Vector<String>();
    Vector<String> classCodes = new Vector<String>();
    DefaultListModel stuListModel = new DefaultListModel();

    /** Creates new form getFeeList */
    public getFeeList(java.awt.Frame parent, boolean modal, MainFrame pparent, Vector<String> names, Vector<String> classCodes) {
        super(parent, modal);
        this.parent = pparent;
        this.names = names;
        this.classCodes = classCodes;
        initComponents();
        this.jListStu.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        for (int i = 0; i < names.size(); i++) {
            String content = names.get(i) + " " + classCodes.get(i) + " " + codecMethodNew.getMeaning(classCodes.get(i));
            this.stuListModel.addElement(content);
        }
        this.jListStu.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent e) {
                if (jListStu.getSelectedIndex() != -1) {
                    if (e.getClickCount() == 1) {
                        oneNewClick(jListStu.getSelectedValue());
                    }
                    if (e.getClickCount() == 2) {
                        twoNewClick(jListStu.getSelectedValue());
                    }
                }
            }
        });

        this.setTitle("欠费学生列表");
        this.setLocationRelativeTo(null);

    }

    void oneNewClick(Object value) {
    }

    void twoNewClick(Object value) {
        //提取主键
        StringTokenizer st = new StringTokenizer(this.jListStu.getSelectedValue().toString());
        Vector<String> temp = new Vector<String>();
        while (st.hasMoreTokens()) {
            //System.out.println(st.nextToken());
            temp.add(st.nextToken());
        }
        String name = temp.get(0);
        String classCode = temp.get(1);
        String className = temp.get(2);
        int result = JOptionPane.showConfirmDialog(null, "要打印交费通知单吗", "提示", JOptionPane.YES_NO_OPTION);
        // int result = JOptionPane.showConfirmDialog(null, "要打印吗？", "提示", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
        //System.out.println(result);
        if (result == 0) {//打印
            WordService word = new WordService(name, classCode);
            word.generateDoc();
            PrintTest.printDoc(PrintTest.getPath() + "\\催费通知单\\" + name + ".doc");
        } else {//不打印
            WordService word = new WordService(name, classCode);
            word.generateDoc();
            PrintTest.showDoc(PrintTest.getPath() + "\\催费通知单\\" + name + ".doc");
        }



    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListStu = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jListStu.setFont(new java.awt.Font("华文细黑", 0, 24)); // NOI18N
        jListStu.setModel(stuListModel);
        jListStu.setToolTipText("双击某一项可查看或打印催费通知单");
        jScrollPane1.setViewportView(jListStu);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 591, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
        getFeeList dialog = new getFeeList(new javax.swing.JFrame(), true);
        dialog.addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent e) {
        System.exit(0);
        }
        });
        dialog.setVisible(true);
        }
        });*/
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList jListStu;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
